package cn.tju.yanbo.homepage;


import cn.tju.yanbo.commons.BaseActivity;
import cn.tju.yanbo.commons.db.AppDatabase;

import cn.tju.yanbo.R;
import cn.tju.yanbo.calendar.LunarCalendarActivity;
import cn.tju.yanbo.datechoose.DateChooseActivity;
import cn.tju.yanbo.goodoccasion.GoodOccasionActivity;
import cn.tju.yanbo.luckyday.LuckyDayActivity;
import cn.tju.yanbo.setting.SettingActivity;
import cn.tju.yanbo.utils.AppUtils;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.AbsoluteLayout.LayoutParams;
import android.widget.AbsoluteLayout;
import android.widget.TextView;

public class HomepageActivity extends BaseActivity {
    /** Called when the activity is first created. */

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.getWindowManager().getDefaultDisplay()
                .getMetrics(AppUtils.SCREEN_METRICS);

        setContentView(R.layout.homepage);
        this.initActivity(savedInstanceState);

        // location
        // this.openWifi();
        if (!this.openGprs()) {
            this.finish();
            return;
        }
        
        this.setLocationView();
        this.setWeatherView();
        
        AppDatabase.startDBService(this.getFilesDir()+"/almanac.db3");
    }

    protected void registerIntent() {
        registerIntent(R.id.menu_lunar_calendar, LunarCalendarActivity.class);
        registerIntent(R.id.menu_datechoose, DateChooseActivity.class);
        registerIntent(R.id.menu_good_occasion, GoodOccasionActivity.class);
        registerIntent(R.id.menu_lucky_day, LuckyDayActivity.class);
        registerIntent(R.id.menu_setting, SettingActivity.class);
    }

    @Override
    protected boolean hasDateView() {
        return true;
    }

    @Override
    protected Class<?> leftActivity() {
        return SettingActivity.class;
    }

    @Override
    protected Class<?> rightActivity() {
        return LunarCalendarActivity.class;
    }
    
    @Override
    protected Drawable background() {
        return CACHED_PICTURES.get(R.drawable.homepage);
    }
    
}